{extend name="public/user" /}

{block name="content"}

	<div class="fly-msg" style="margin-bottom: 20px;"> 
		Hi，<span style="color: red">{:session('user_name')}</span>，你已是我们的正式社员。
	</div>
	<div class="layui-row layui-col-space20"> 
	<div class="layui-col-md6"> 
	{include file="public/sign" /}
<!--		<div class="fly-panel fly-signin fly-panel-border"> 
		<div class="fly-panel-title"> 签到 
		<i class="fly-mid"></i> 
		<a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a> 
		<i class="fly-mid"></i> 
		<a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜<span class="layui-badge-dot"></span></a> 
		<span class="fly-signin-days">已连续签到<cite>0</cite>天</span> </div> 
		<div class="fly-panel-main fly-signin-main">
		<button class="layui-btn layui-btn-danger" id="LAY_signin">今日签到</button>
		<span>可获得<cite>5</cite>飞吻</span>
		</div> 
		</div>
-->		
	</div> 
	<div class="layui-col-md6"> 
	<div class="fly-panel fly-panel-border"> <div class="fly-panel-title"> 我的会员信息 </div> 
	<div class="fly-panel-main layui-text" style="padding: 18px 15px; height: 50px; line-height: 26px;"> 
	<p>您的财富经验值：<span style="color: red">{$user.point}</span> 金币</p> <p>您当前为：<span style="color: red">非 VIP</span></p> </div> </div> </div>
	
		<div class="layui-col-md12" style="margin-top: -20px;"> 
			<div class="fly-panel fly-panel-border"> <div class="fly-panel-title"> 快捷方式 </div> 
				<div class="fly-panel-main"> 
					<ul class="layui-row layui-col-space10 fly-shortcut"> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="{:url('user/set')}"><i class="layui-icon"></i><cite>修改信息</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="{:url('user/set#avatar')}"><i class="layui-icon"></i><cite>修改头像</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="{:url('user/set#pass')}"><i class="layui-icon"></i><cite>修改密码</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="/user/set/#bind"><i class="layui-icon"></i><cite>帐号绑定</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="{:url('article/add')}"><i class="layui-icon"></i><cite>发表新帖</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="/column/share/"><i class="layui-icon"></i><cite>查看分享</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4 LAY_search "> <a href="javascript:;"><i class="layui-icon"></i><cite>搜索资源</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="{:url('user/post/#collection')}"><i class="layui-icon"></i><cite>我的收藏</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="/jie/15697/"><i class="layui-icon"></i><cite>成为赞助商</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="/jie/2461/"><i class="layui-icon"></i><cite>关注公众号</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="http://www.test.com/doc/"><i class="layui-icon"></i><cite>文档</cite></a> </li> 
						<li class="layui-col-sm3 layui-col-xs4"> <a href="http://www.test.com/demo/"><i class="layui-icon"></i><cite>示例</cite></a> </li> 
					</ul> 
				</div> 
			</div> 
		</div> 
	</div>

{/block}

{block name="script"}
<script>
    layui.use(['form', 'layer'], function() {
        var layer = layui.layer;
        var $ = layui.jquery;
        var jifenname = "金币";
        var uid = "{:session('user_id')}";
        if (uid != '') {
            $.get("{:url('index/sign/todayData')}", function(data) {

                $('.fly-signin-days').html('已连续签到<cite>' + data.days + '</cite>天');

                if (data.is_sign == 1) {

                    $('.fly-signin-main').html('<button class="layui-btn layui-btn-disabled">今日已签到</button><span>获得了<cite>' + data.score + '</cite>' + jifenname + '</span>');

                } else {
                    $('.fly-signin-main').html('<button id="LAY_signin" class="layui-btn layui-btn-danger">今日签到</button><span>可获得<cite>' + data.will_getscore + '</cite>' + jifenname + '</span>');

                    $("#LAY_signin").on("click", function() {

                        $.getJSON("{:url('index/sign/sign')}", function(data) {

                            if (data.code == 200) {
                                $('.fly-signin-days').html('已连续签到<cite>' + data.days + '</cite>天');
                                $('.fly-signin-main').html('<button class="layui-btn layui-btn-disabled">今日已签到</button><span>获得了<cite>' + data.score + '</cite>' + jifenname + '</span>');
                                if (data.msg != '') {
                                    layer.msg(data.msg, {
                                        icon: 6,
                                        time: 5000
                                    },function () {
									location.reload(true);
									});
                                }
                            } else {
                                layer.msg(data.msg);
                            }
                        });
                    });
                }
            });
        } else {
            $('.fly-signin-main').html('<button class="layui-btn layui-btn-danger" id="LAY_signin">签到得' + jifenname + '</button>');
            $("#LAY_signin").on("click", function() {
                layer.msg('请先登录');
            });
        }

        //查看签到积分规则
        $("#LAY_signinHelp").on("click", function() {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            var url = "{:url('index/sign/getsignrule')}";


            $.getJSON(url, function(data) {
                $str = '';
                $.each(data.msg, function(k, v) {
                    $str += '<tr><td>≥' + v.days + '</td><td>' + v.score + '</td></tr>';
                });
                var content = '<div class="layui-text" style="padding: 20px;">' +
                    '<blockquote class="layui-elem-quote">“签到”可获得社区' + jifenname + '，规则如下</blockquote>' +
                    '<table class="layui-table">' +
                    '<thead>' +
                    '<tr><th>连续签到天数</th><th>每天可获' + jifenname + '</th></tr>' +
                    '</thead>' +
                    '<tbody>' +
                    $str +
                    '</tbody>' +
                    '</table>' +
                    '<ul>' +
                    '<li style="color: #FF5722;">新年期间签到额外赠送最高99金币</li>' +
                    '<li>中间若有间隔，则连续天数重新计算</li>' +
                    // '<li style="color: #FF5722;">不可利用程序自动签到，否则' + jifenname + '清零</li>' +
                    '</ul></div>'
                layer.open({
                    type: 1,
                    title: '签到说明',
                    area: '300px',
                    shade: 0.8,
                    shadeClose: true,
                    content: content,
                    success: function(index, layero) {
                        //do something
                        layer.close(loading); //如果设定了yes回调，需进行手工关闭
                    }
                });
            });
        });

        //查看积分榜单
        $("#LAY_signinTop").on("click", function() {

            var signlisturl = "{:url('index/sign/lists')}";

            layer.open({
                type: 2,
                title: '签到活跃榜 - TOP 20',
                shade: 0.8,
                area: ['300px', '430px'], //宽高
                scrollbar: false,
                shadeClose: true,
                content: signlisturl,
            });
        });
    });
</script>

<script>
    layui.cache.page = 'user';
    layui.cache.user = {
        username: '{$user.name??'游客'}'
        ,uid: {$user.id ? 168*$user.id : -1}
        ,avatar: '{if condition="$user['user_img'] neq ''"}/uploads/{$user['user_img']}{else /}/static/res/images/avatar/00.jpg{/if}'
        ,experience: 83
        ,sex: '{if condition="$user['sex'] eq 0"}男{else/}女{/if}'
    };
    layui.config({
        version: "3.0.0"
        ,base: '/static/res/mods/'
    }).extend({
        fly: 'index'
    }).use('fly');
</script>
{/block}